package studentIspit;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;

public class Ispit {
	private int brojStudenata;
	private ArrayList<Student> studenti;
	private Iterator<Student> iterator;
	private ArrayList<String> studentiPolozili = new ArrayList<String>();

	public Ispit(int brojStudenata) {
		this.brojStudenata = brojStudenata;

		this.studenti = new ArrayList<Student>();

		for (int i = 0; i < this.brojStudenata; i++) {
			this.studenti.add(new Student());
		}
		// Unos podataka za pojedine objekte Student
		this.iterator = this.studenti.iterator();
		while (this.iterator.hasNext()) {
			this.iterator.next().readStudentFromKeyboard();
		}

	}

	public void printStudenti() {
		// print studenata rijesen preko for each petlje
		System.out.println("Spisak studenat koji su dosli na ispit: ");
		for (Student s : studenti) {
			System.out.println("ime - prezime - godina: " + s.toString());
		}
		System.out.println();
		// print studenata rjesen preko iteratora
		// this.iterator = this.studenti.iterator();
		// while (this.iterator.hasNext())
		// {
		// System.out.println(this.iterator.next());
		// }
	}

	public void addPolozili() {
		System.out.println("Ukupno ima studenata " + brojStudenata
				+ " polozili su :");
		this.brojStudenata++;
		for (Student s : studenti) {
			this.studentiPolozili.add(s.getIme() + " " + s.getPrezime());
			System.out.println(studentiPolozili.toString());
		}

	}

	public void removeStudent() {
		Random r = new Random();
		int i = r.nextInt(studenti.size());

		System.out.println("Sadrzaj liste prije ulaska na ispit: "
				+ studenti.toString() + " -- " + " ukupno studenata je: "
				+ studenti.size());

		studenti.remove(i);
		
		System.out
				.println("Sadrzaj liste posle izbacivanja studenata sa ispita: "
						+ studenti.toString()
						+ " -- "
						+ " ukupno studenata je: " + studenti.size() + "\n");
	}

}
